﻿using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Rs;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Rs;

namespace VisionCloud.Api.Controllers.Rs
{
    /// <summary>
    /// 工单管理
    /// </summary>
    [SystemModule("工单模块控制器")]
    [ApiAuthorize(PolicyEnum.RequireRolePermission)]
    [ApiVersion("1.0")]
    [Route("api/rs/[controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "工单模块控制器")]
    public class WorkOrderMapController : ApiBaseController
    {
        public RsWorkOrderMapService RsWorkOrderMapService { get; set; }

        /// <summary>
        /// 新增工单和项目匹配
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> Add(WorkOrderMapRequestDto dto)
        {
            return await TryCatchAsync(RsWorkOrderMapService.Add(dto));
        }


        /// <summary>
        /// 分页获取工单和项目匹配
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        [SwaggerResponse(0, "Data字段为工单列表", typeof(List<WorkOrderMapProjectsResponseDto>))]
        public async Task<ApiResult> GetWorkOrderMapProjects(WorkOrderMapRequestPageDto dto)
        {
            return await TryCatchAsync(RsWorkOrderMapService.GetWorkOrderMapProjects(dto));
        }
    }
}